<?php

abstract class AbstractRouteWidget extends Route
{
    protected $view;

    /**
     * Initializes component
     *
     * @return void
     */
    public function setUrlArguments($params)
    {
        $this->view = Smarty2::Singleton();
        $this->view->assign('component_name', $this->objectName);

        parent::setUrlArguments($params);
    }

    public function render($template)
    {        
        $olddir = $this->view->template_dir;
        $filename = typeOf($this)->getFileName();
        $path = dirname($filename) . '/' . $name;
        if( !file_exists($path.'/'.$template) ) {
            throw new Exception('Template '.$template.' not found in '.$path);
        }
        $this->view->template_dir = $path;
        $ret = $this->view->fetch($template);
        $this->view->template_dir = $olddir;
        return $ret;
    }

    abstract function display();
}